/**
 * Copyright (c) 2009, http://www.softwareinlife.com. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, 
 * with or without modification, are permitted provided that 
 * the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 * 
 * 3. Neither the name of the http://www.softwareinlife.com nor the names of its 
 *    contributors may be used to endorse or promote products derived from 
 *    this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE SOFTWAREINLIFE AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.softwareinlife.vision.android.information.dao;

import java.util.List;

import android.content.Context;

import com.softwareinlife.vision.android.information.exceptions.DatabaseConnectionException;
import com.softwareinlife.vision.android.information.model.UserModel;

/**
 * @author Jang, Sun-Jin(jangsunjin@softwareinlife.com)
 * @date 2009. 9. 21.
 * 
 */
public class UserDAO extends BaseDAO {

	/**
	 * Serial Version UID
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Table Name of User Model
	 */
	public static final String TABLE_NAME = "VS_USER";

	/**
	 * Table Create SQL
	 */
	private static final String TABLE_SQL_CREATE = "CREATE TABLE IF NOT EXISTS "
			+ TABLE_NAME
			+ " (LastName VARCHAR, FirstName VARCHAR,"
			+ " Country VARCHAR, Age INT(3));";

	/**
	 * Table Delete SQL
	 */
	private static final String TABLE_SQL_DELETE = "DELETE TABLE IF EXIST " + TABLE_NAME;

	/**
	 * @param ctx
	 * @throws DatabaseConnectionException
	 */
	public UserDAO(Context ctx) throws DatabaseConnectionException {
		super(ctx);
	}

	/**
	 * Create User
	 * 
	 * @param user
	 */
	public void create(UserModel user) {
		db.execSQL("INSERT INTO " + TABLE_NAME
				+ " (LastName, FirstName, Country, Age)"
				+ " VALUES ('Gramlich', 'Nicolas', 'Germany', 20);");
//		db.insert(TABLE_NAME, nullColumnHack, values)
	}

	/**
	 * Read Users
	 * 
	 * @return
	 */
	public List<UserModel> readAll() {
//		Cursor c = db.query(TABLE_NAME, columns, selection, selectionArgs,
//				groupBy, having, orderBy);
//
//		if (c != null && c.getCount() > 0) {
//			/* Check if at least one Result was returned. */
//			if (c.first()) {
//				int i = 0;
//				/* Loop through all Results */
//				do {
//					i++;
//					/*
//					 * Retrieve the values of the Entry the Cursor is pointing
//					 * to.
//					 */
//					String firstName = c.getString(firstNameColumn);
//					int age = c.getInt(ageColumn);
//					/*
//					 * We can also receive the Name of a Column by its Index.
//					 * Makes no sense, as we already know the Name, but just to
//					 * shwo we can Wink
//					 */
//					String ageColumName = c.getColumnName(ageColumn);
//
//					/* Add current Entry to results. */
//					results.add("" + i + ": " + firstName + " (" + ageColumName
//							+ ": " + age + ")");
//				} while (c.next());
//			}
//
//		}
		return null;
	}

	/**
	 * Update User
	 * 
	 * @param user
	 */
	public void update(UserModel user) {

	}

	/**
	 * Delete User
	 * 
	 * @param userId
	 */
	public void delete(String userId) {

	}

	@Override
	void createTable() {
		db.execSQL(TABLE_SQL_CREATE);
	}

	@Override
	void deleteTable() {
		db.execSQL(TABLE_SQL_DELETE);
	}
}
